{php include wl_template('common/header-base');}
{php include wl_template('diy/common/_common');}
<div class="app-content">
    <ul class="nav nav-tabs diypage-nav-tabs" style="margin: 0;">
        <li class="li-flo-le"><a href="{php echo web_url($back)}" class="diypage-back"><i class="icon iconfont icon-back_android"></i>返回</a></li>
        <li><a href="javascript:;" class="diypage-save-page btn-save" data-type="save" ><i class="icon iconfont icon-upload"></i>保存页面</a></li>
        <li><a href="javascript:;" class="diypage-icon-txt btn-save" data-type="preview"><i class="icon iconfont icon-attention"></i>预览</a></li>
        <li><a href="javascript:;" class="diypage-icon-txt btn-save" data-type="savetemp" ><i class="icon iconfont icon-youji1"></i>保存模板</a></li>
        <li><a href="javascript:;" class="diypage-icon-txt pageset"><i class="icon iconfont icon-shezhi1"></i>设置</a></li>
        <li><a href="javascript:;" id="full-screen"><i class="icon iconfont icon-full"></i></a><a href="javascript:;" style="display: none;" id="exit-screen"><i class="icon iconfont icon-suoxiao"></i></a></li>
    </ul>
    <div class="main panel panel-default">
        <div class="page-content">
            <div class="row relative pagediy">
                <!--菜单内容-->
                <div class="diy-menu">
                    <div class="navs" id="navs"></div>
                </div>
                <!--页面主要内容-->
                <div id="phone-margin">
                    <div class="diy-phone" data-merch="{php echo intval($_W['merchid'])}">
                        <div class="phone-head"></div>
                        <div class="phone-body">
                            <div class="phone-title" id="page">loading...</div>
                            <div class="phone-main" id="phone">
                                <p style="text-align: center; line-height: 400px">您还没有添加任何元素</p>
                            </div>
                        </div>
						<div class="phone-custom" id="custom" style="width: 100%; padding: 11px; box-sizing: border-box; background-color: #ffffff; 
						border-top: 0.5px solid #eeeeee; display: flex; font-size: 8px; justify-content: space-around; align-items: center;">
							<div class="" style="display: flex; align-items: center; flex-direction: column;">
								<div>
									<span class="iconfont tabbar-item-icon icon-home" style="font-size: 22px;"></span>
								</div>
								<span class="bottom-text1">商户</span>
							</div>
							<div class="" style="display: flex; align-items: center; flex-direction: column;">
								<div>
									<span class="iconfont tabbar-item-icon icon-tupian" style="font-size: 22px;"></span>
								</div>
								<span class="bottom-text1">海报</span>
							</div>
							<div class="claimbutton" style="width: 50%; height: 55px; background-color: #FF6A50; border-radius: 11px; 
							color: #ffffff; text-align: center; font-size: 16px; line-height: 55px;">
								立即领取
							</div>
						</div>
                        <div class="phone-foot"></div>
                    </div>
                    <!--返回顶部按钮-->
                    <div id="backTop" class="backTop hide">
						<i class="icon iconfont icon-fold"></i>
                    </div>
                </div>
                <!--组件配置信息-->
                <div class="diy-editor form-horizontal" id="diy-editor">
                	<div class="adv_title_page_title">
	                    <div id="adv_title">本页面编辑</div>
	                    <div id="page_title">
	                        <span class="page_name active" id="nav_config">配置</span>
	                        <span class="page_name" id="nav_type">风格</span>
	                    </div>
	                </div>
                    <div class="inner inner_content" page_id="nav_config"></div>
                    <div class="inner_content" page_id="nav_type" id="createNavContent"></div>
                </div>
            </div>
            {php include wl_template('diy/common/_template');}
            {php include wl_template('diy/common/_template_edit');}
        </div>
    </div>
</div>
<script type="text/javascript" src="./resource/components/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="./resource/components/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="./resource/components/ueditor/lang/zh-cn/zh-cn.js"></script>
<script language="javascript">
    var path = 'diy/js/diy.min';
    myrequire([path,'diy/js/tpl','js/biz'],function(modal,tpl){
        modal.init({
            pageType:"{$page_type}",
            tpl: tpl,
            attachurl: "{$_W['attachurl']}",
            id: "{$id}",
            type: "{$type}",
            goodCate:{php echo json_encode($common['goodCate'])},
            community_list:{php echo json_encode($common['community_list'])},
            data: {if !empty($result['data'])}{php echo json_encode($result['data'])}{else}null{/if},
            diymenu: {php echo $result['data']['page']['diymenu']?$result['data']['page']['diymenu']:0},
            diyadv: {php echo $result['data']['page']['diyadv']?$result['data']['page']['diyadv']:0},
            levels: null,
            merch: 0,
            plugins: {$common['hasplugins']},
            menulist:{php echo json_encode($diymenu)},
            advlist:{php echo json_encode($diyadvs)},
        });
    });
    function selectUrlCallback(href){
        var ue =  UE.getEditor('rich');
        if(href){
            ue.execCommand('link', {href: href, 'data-nocache': 'true'});
        }
    }
    function callbackGoods(data) {
        myrequire([path],function(modal) {
            modal.callbackGoods(data);
        });
    }
    function callbackCategory (data) {
        myrequire([path],function(modal) {
            modal.callbackCategory(data);
        });
    }
    function callbackGroup (data) {
        myrequire([path],function(modal) {
            modal.callbackGroup(data);
        });
    }
    function callbackMerch (data) {
        myrequire([path],function(modal) {
            modal.callbackMerch(data);
        });
    }
    function callbackMerchCategory (data) {
        myrequire([path],function(modal) {
            modal.callbackMerchCategory(data);
        });
    }
    function callbackMerchGroup (data) {
        myrequire([path],function(modal) {
            modal.callbackMerchGroup(data);
        });
    }
    function callbackSeckill (data) {
        myrequire([path],function(modal) {
            modal.callbackSeckill(data);
        });
    }
    function callbackCoupon (data) {
        myrequire([path],function(modal) {
            modal.callbackCoupon(data);
        });
    }
    var winHight = '';
    $('#full-screen').click(function(){
        $('#full-screen').hide();
        $('#exit-screen').show();
        var el = document.documentElement;
        var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen;
        winHight = $(window).height();
        if(typeof rfs != "undefined" && rfs) {
            rfs.call(el);
        };
        return;
    });
    $('#exit-screen').click(function(){
        $('#exit-screen').hide();
        $('#full-screen').show();
        var elem = document;
        if(elem.webkitCancelFullScreen){
            elem.webkitCancelFullScreen();
        }else if(elem.mozCancelFullScreen){
            elem.mozCancelFullScreen();
        }else if(elem.cancelFullScreen){
            elem.cancelFullScreen();
        }else if(elem.exitFullscreen){
            elem.exitFullscreen();
        }else{
            alert('浏览器不支持全屏API或已被禁用');
        }
    });
    $(window).resize(function(){
        if(winHight !== '' && winHight >= $(window).height()){
            $('#exit-screen').hide();
            $('#full-screen').show();
        }
    });
    //判断是否显示回到顶部的按钮
    $("#phone-margin").scroll(function () {
        var distanceTop = $("#phone-margin").scrollTop();
        if(distanceTop > 200){
            $(".backTop").removeClass("hide");
        }else if(!$(".backTop").hasClass("hide")){
            $(".backTop").addClass("hide");
        }
    });
    //点击回到顶部
    $(".backTop").on('click',function () {
        $("#phone-margin").scrollTop(0);
    });


</script>
<script>
    function showAudioDialog(elm, base64options, options) {
        require(["util"], function (util) {
            var btn = $(elm);
            var ipt = btn.parent().prev();
            var val = ipt.val();
            util.audio(val, function (url) {
                if (url && url.attachment && url.url) {
                    btn.prev().show();
                    ipt.val(url.url);
                    ipt.change();
                    ipt.attr("filename", url.filename);
                    ipt.attr("url", url.url);
                    setAudioPlayer();
                }
                if (url && url.media_id) {
                    ipt.val(url.media_id);
                }
            }, "", {"direct": true, "multiple": false, "fileSizeLimit": 204800000});
        });
    }
    function setAudioPlayer(){
        require(["jquery.jplayer"], function(){
            $(function(){
                $(".audio-player").each(function(){
                    $(this).prev().find("button").eq(0).click(function(){
                        var src = $(this).parent().prev().val();
                        if($(this).find("i").hasClass("fa-stop")) {
                            $(this).parent().parent().next().jPlayer("stop");
                        } else {
                            if(src) {
                                $(this).parent().parent().next().jPlayer("setMedia", {mp3: util.tomedia(src)}).jPlayer("play");
                            }
                        }
                    });
                });
                $(".audio-player").jPlayer({
                    playing: function() {
                        $(this).prev().find("i").removeClass("fa-play").addClass("fa-stop");
                    },
                    pause: function (event) {
                        $(this).prev().find("i").removeClass("fa-stop").addClass("fa-play");
                    },
                    swfPath: "resource/components/jplayer",
                    supplied: "mp3"
                });
                $(".audio-player-media").each(function(){
                    $(this).next().find(".audio-player-play").css("display", $(this).val() == "" ? "none" : "");
                });
            });
        });
    }
    $("#diy-editor").on('click','#musicPlaying',function () {
        setAudioPlayer();
    });
</script>
{php include wl_template('common/footer');}